/**
 * 创建form表单的自定义校验规则
 */
export function createCallback({
  prop,
  required = true,
  trigger = "",
  validator = (rule, value, callback) => {
    callback();
  },
}) {
  if (Array.isArray(validator)) {
    return {
      [prop]: validator.map((v) => ({
        required,
        ...(trigger.length ? { trigger } : {}),
        validator: v,
      })),
    };
  } else
    return {
      [prop]: {
        required,
        ...(trigger.length ? { trigger } : {}),
        validator,
      },
    };
}
